﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢喜过新年,拼手气分2亿</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="http://cdn.iyaoread.com/js/jquery-1.8.1.min.js"></script>
    <style>
        *{margin: 0;padding: 0;}
        header{width: 100%;background: #de574f;;padding-top: 15px}
        footer{width: 100%;;position: fixed;bottom: 0;left: 0;vertical-align: bottom;background: #fff}
        footer a{width:20%;display: inline-block;vertical-align: bottom;float: left}
        footer a img{width: 100%;}
        .g_d1{width: 93%;height: 60px;background: #fff;margin: 0 auto;border-radius: 10px;padding-top: 10px}
        .g_d2{width: 50%;height: 50px;float: left;background: #fff}
        .g_d2 h4{margin-left: 20px;background: #fff}
        .g_d2 p{margin-left: 20px;margin-top: 10px;color: #de554d;font-size: 16px;background: #fff}
        .g_d2 p i{font-size: 22px;font-style: normal;background: #fff}
        .g_d1 a{width: 100px;height: 35px;line-height: 35px;text-align: center;display: block;float: right;margin-right: 20px;border-radius: 5px;background: #de554d;margin-top: 8px;color: #fff;text-decoration: none}
        .clear{width: 100%;height: 15px;background: #de554d}
        .thead{width: 100%;height: 40px;;background: #f0f0f0;line-height: 40px}
        .thead h4{margin-left: 10px;font-size: 16px;font-weight: normal;background: #f0f0f0}
        .tbody{background: #fff}
        .list{width: 90%;height: 60px;margin: 0 auto;background: #fff;border-bottom: 1px solid #f0f0f0}
        .list-left{float: left;width: 70%;height: 60px;background: #fff;}
        .list-left h5{background: #fff;margin: 10px 0 8px 0 ;font-weight: normal;font-size: 16px}
        .list-left h5 i{font-style: normal;color: #de554d;background: #fff}
        .list-left span{background: #fff;font-size: 14px;color: #b7b7b7}
        .list-right{width: 30%;height: 60px;float: right;;line-height: 60px}
        .earn{font-size: 14px;color: #078307;background: #fff;text-align: right}
        .Loss{font-size: 14px;color: #de554d;background: #fff;text-align: right}
    </style>
</head>
<body style="background: #f5f5f5">
<header>
   <div class="g_d1">
       <div class="g_d2">
           <h4 style="">当前余额</h4>
           <p style=""><i id="amount_i">0</i>元</p>
       </div>
       <a id="Withdrawals">提 现</a>
   </div>
    <div class="clear"></div>
</header>
<section>
     <div class="thead">
          <h4>记录明细</h4>
     </div>
      <div class="tbody" id="tbody_id">
      </div>
</section>
<footer>
    <a href="index.html"><img src="http://yuedupic.iyaoread.com/hongbao/qiangUn.png" alt=""/></a>
    <a><img src="http://yuedupic.iyaoread.com/hongbao/payOn.png" alt=""/></a>
    <a href="Commission.html"><img src="http://yuedupic.iyaoread.com/hongbao/yongJUn.png" alt=""/></a>
    <a href="agent.html"><img src="http://yuedupic.iyaoread.com/hongbao/dailiUn.png" alt=""/></a>
    <a href="service.html"><img src="http://yuedupic.iyaoread.com/hongbao/kefuUn.png" alt=""/></a>
</footer>
<script src="js/properties.js"></script>
<script>
	var falg = true;
    function withdrawalsClick(){
    	var amount = $("#amount_i").html();
    	if(amount > 1){
        	if (falg) {
        		falg = false;
                $.ajax({
                    type: 'GET',
                    url: "/activity/withdrawals",
                    dataType:"json",
                    success:function(data){
                        if(data.code == 0){
                            alert('提现成功,请您在公众号“龙虎28”领取红包！');
                            window.location.reload();//刷新当前页面.;
                        }else if(data.code == 1){
                        	alert("提现失败,请联系客服处理!");
                        	falg = true;
                        }
                    },
                    error:function(data){
                      falg = true;
                    }
                });
        	}
    	} else {
            alert("余额大于1元时才可提现!");
    	}
    }
	$("#Withdrawals").on("click",withdrawalsClick);
    var a = "";
    $(".tbody").append()
    var partakeList = function(){
        $.ajax({
            type: 'GET',
            url: "/activity/partakeList",
            dataType:"json",
            success:function(data){
              if(data.code==0){
            	  var amount = toDecimal(data.data.amount/100);
            	  $("#amount_i").html(amount);
            	  for(var i =0;i<data.data.partake.length;i++){
            		  var html1=$("#tbody_id").html();
            		  var payAmount = toDecimal(data.data.partake[i].payAmount/100.0);
            		  var gainAmount = toDecimal(data.data.partake[i].gainAmount/100.0);
            		  var num = 0;
            		  var str = "";
            		  var cl = "";
            		  if(payAmount>gainAmount){
            			  cl = "Loss";
            			  num = toDecimal(payAmount - gainAmount);
            			  str = "亏了"+num+"元";
            		  }else{
            			  cl = "earn";
            			  num = toDecimal(gainAmount - payAmount);
            			  str = "赚了"+num+"元";
            		  }
            		  var payType = '微信支付';
            		  if(data.data.partake[i].payType=='BALANCE'){
            			  payType = '余额支付';
            		  }
            		  $("#tbody_id").html(html1+"<div class=\"list\"><div class=\"list-left\" style=\"\"><h5>"+payType+payAmount+"元 获得红包 <i>"+gainAmount+"元</i></h5><span>"+data.data.partake[i].partakeTime+"</span></div><div class=\"list-right\"><p class=\""+cl+"\">"+str+"</p></div></div>");
            	  }
              }else if(data.code=99){
            	  window.location = baseUrl+"activity/homePage/grabMoney";
              }else{
              	alert(data.data);
              }
            },
            error:function(data){
            }
        });
    }
    $(document).ready((partakeList));
    function toDecimal(x) { 
      var f = parseFloat(x); 
      if (isNaN(f)) { 
        return; 
      } 
      f = Math.round(x*100)/100; 
      return f; 
    } 

</script>
</body>
</html>